import service from "@/utils/request";

// 注册方法
export function register(name: string, mobile: string, password: string, captcha: string, captcha_id: string) {
  const data = {
    username: name,
    password,
    mobile,
    captcha,
    captchaUuid: captcha_id
  };
  return service({
    url: "/user/register",
    headers: {
      isToken: false
    },
    method: "post",
    data: data
  });
}

export function changePhoneNumApi(mobile: string, captcha: string, captcha_id: string) {
  const data = {
    mobile,
    captcha,
    captchaUuid: captcha_id
  };
  return service({
    url: "/user/changeMobile",
    method: "post",
    headers: {
      isToken: true
    },
    data
  });
}

// 获取验证码方法
export function captchaWithVerify(phone_num: string) {
  const data = {
    mobile: phone_num
  };
  return service({
    url: "/user/getCaptchaWithVerify",
    headers: {
      isToken: false
    },
    method: "post",
    data
  });
}

export function verifyUserNameApi(name: string) {
  const data = {
    username: name
  };
  return service({
    url: "/user/verifyName",
    headers: {
      isToken: false
    },
    method: "get",
    params: data
  });
}

// 获取验证码方法
export function captcha(phone_num: string) {
  const data = {
    mobile: phone_num
  };
  return service({
    url: "/user/getCaptcha",
    headers: {
      isToken: false
    },
    method: "post",
    data
  });
}

